<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  xmlns:doc="livcos.org/ns/doc"
  xmlns:pm="livcos.org/ns/pm"
  xmlns:f="livcos.org/ns/xslt/function"
  xmlns="livcos.org/ns/doc"
  exclude-result-prefixes="doc pm f">
  
  <xsl:import href="../../../style/base.xsl"/>
	
	<xsl:param name="ref" select="'../../data/pm/Roadmap'"/>
  
  <xsl:template match="/">
    <xsl:apply-templates select="document($ref)/*"/>
  </xsl:template>
  
  <xsl:template match="@* | node()">
    <xsl:copy>
      <xsl:apply-templates select="@* | node()"/>
    </xsl:copy>
  </xsl:template>
  
  <xsl:template match="/*">
    <xsl:copy>
      <xsl:attribute name="id"><xsl:value-of select="f:object-id(.)"/></xsl:attribute>
      <xsl:apply-templates select="@* | node()"/>
    </xsl:copy>
  </xsl:template>
  
  <xsl:template match="doc:chapter[@id = 'chapter_5']">
    <xsl:apply-templates select="pm:application[1]"/>
    <xsl:copy>
      <xsl:apply-templates select="@*"/>
      <xsl:apply-templates select="doc:*"/>
      <xsl:apply-templates select="pm:application[position() &gt; 1]"/>
    </xsl:copy>
  </xsl:template>
  
  <xsl:template match="pm:application">
    <chapter id="{@id}">
      <xsl:apply-templates select="*"/>
    </chapter>
  </xsl:template>
  
  <xsl:template match="pm:release">
    <chapter id="{@id}" type="release">
      <title>
        <xsl:text>Release </xsl:text>
        <xsl:value-of select="@num"/>
        <xsl:if test="@label">
          <xsl:text> </xsl:text>
          <xsl:value-of select="@label"/>
        </xsl:if>
      </title>
      <xsl:apply-templates select="*"/>
    </chapter>
  </xsl:template>
  
  <xsl:template match="pm:feature">
    <chapter id="{@id}" type="feature">
      <xsl:apply-templates select="*"/>
    </chapter>
  </xsl:template>
  
  <xsl:template match="pm:feature/doc:title">
    <title>Feature: <xsl:apply-templates select="node()"/></title>
  </xsl:template>
  
</xsl:stylesheet>
